package com.lanchewuyou.user.driver.layouts;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.lanchewuyou.user.driver.R;

/**
 * 已弃用
 */
public class ImageButton extends LinearLayout {
    private ImageView imageView;
    private TextView textView;
    private View view1, view2, view3, view4;

    public ImageButton(Context context) {
        super(context);
    }

    public ImageButton(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.imagebutton, this);
        imageView = (ImageView) findViewById(R.id.small_img);
        textView = (TextView) findViewById(R.id.small_img_text);
        view1 = (View) findViewById(R.id.imagebtnview1);
        view2 = (View) findViewById(R.id.imagebtnview2);
        view3 = (View) findViewById(R.id.imagebtnview3);
        view4 = (View) findViewById(R.id.imagebtnview4);
    }

    public void setImageView(Bitmap bitmap) {
        imageView.setImageBitmap(bitmap);
    }

    public void setImageView(int id) {
        imageView.setImageResource(id);
    }

    public void setImageBtnColor(int id) {
        switch (id) {
            case 1:
                view1.setBackgroundColor(getResources().getColor(R.color.mainred));
                view2.setBackgroundColor(getResources().getColor(R.color.mainred));
                view3.setBackgroundColor(getResources().getColor(R.color.mainred));
                view4.setBackgroundColor(getResources().getColor(R.color.mainred));
                break;
            case 2:
                view1.setBackgroundColor(getResources().getColor(R.color.grey));
                view2.setBackgroundColor(getResources().getColor(R.color.grey));
                view3.setBackgroundColor(getResources().getColor(R.color.grey));
                view4.setBackgroundColor(getResources().getColor(R.color.grey));
            default:
                break;
        }
    }

    public void setTextView(String text) {
        textView.setText(text);
    }
}
